<?php
/**
 * 我的商户
 * @author Administrator
 *
 */
class shop extends CControllerOwnerLoginBase{
	
	public function show()
	{
		$shopModel = new ownerShopModel();
		$page = $this->getRequestData("page","get",1);
		$c = 0;
		$data = $shopModel->selectPage($page,10,
			"t.shop_id,shop_name,os.balance,os.owner_card_status,sp.pic_path,remark",
			"t.shop_id=os.shop_id and t.del_flag=0 and t.shop_status=1 and t.shop_id=sp.shop_id and os.owner_id=".$this->_ownerID,
			"","",$c,"t_shop t,t_shop_product sp, t_owner_shop os"
		);
		
		$pageStr = CPage::showPage($page,10,$c);
		
		$this->render("shop_list",array("data"=>$data,"pageStr"=>$pageStr));
	}
	
	public function betchChange()
	{
		$type=$this->getRequestData("type");
		$pwd=$this->getRequestData("pwd");
		$ids=$this->getRequestData("ids");
		
		if($type!=1 && $type!=2)
		{
			echo -10;
			exit;
		}
		
		$pwd = CCommon::pwdMd5($pwd);
		
		$ownerModel = new ownerModel();
		if($ownerModel->checkPayPwdByOwner($this->_ownerID,$pwd))
		{
			$idList = explode(",", $ids);
			foreach ($idList as $shopID)
			{
				$ownerModel->changeCardStatusForShop($this->_ownerID,$shopID,$type);
			}
			echo 1;
		}
		else{
			echo -1; //密码不正确
		}
		
		exit;
	}

}